package team.you.ticket.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import team.you.ticket.pojo.Car;
import team.you.ticket.pojo.Result;
import team.you.ticket.service.CarService;

@Controller
@RequestMapping("/carInfo")
public class CarContrller {
    @Autowired
    private CarService carService;

    @RequestMapping("/getAllCars")
    @ResponseBody
    private Result getAllCars(Integer page,Integer limit)
    {
        return carService.getAllCars(page,limit);
    }
    @RequestMapping("/add")
    @ResponseBody
    private Result add(Car car)
    {
        return carService.add(car);
    }
    @RequestMapping("/del")
    @ResponseBody
    private Result del(String id)
    {
        return carService.del(id);
    }
    @RequestMapping("/delete")
    @ResponseBody
    private Result delete(String[] ids)
    {
        return carService.delete(ids);
    }
    @RequestMapping("/update")
    @ResponseBody
    private Result update(String id,String value,String field)
    {
        return carService.update(id,value,field);
    }
    @RequestMapping("/selectByLike")
    @ResponseBody
    private Result selectByLike(String value,String type,Integer page,Integer limit)
    {
        if (type=="")
            type="3";
        return carService.selectByLike(value,type,page,limit);
    }
}
